<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <form action="/index.php/upload/up" method="post" enctype="multipart/form-data">
         <input type="file" id="upload" name="upfile" > 
        <input type="submit" name="sub"  value="提交">
    </form>
    <img src="" alt="" id="image" width=100 height=100>
    <script>
    // function fileInfo (){
    //     console.log('enter');
    //     // var reader = new FileReader();
    //     // reader.onload = function(e){
    //     //     console.log(e.target);
    //     // }
    //     var reader = new FileReader();
    //     reader.onload = function(e){
    //         console.log(e.target.result)
    //     }
    // }
    upload.onchange = function(e){
        console.log(e.target.files[0]);

        var reader = new FileReader();
        reader.readAsDataURL(e.target.files[0]);
        
        reader.onload = function(e){
            console.log(this.result);
            console.log(image.src);
            image.src = this.result;
            // console.log(e.target.result);
        }
    }
    </script>
</body>
</html>